package com.fc.redis;

import com.fc.redis.util.IdWorker;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@MapperScan("com.fc.redis.mapper")
//@EnableCaching // 开启注解式缓存
@EnableAsync
public class RedisApplication {
    /**
     * @author GY
     * @date 2019年9月13日
     */
    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(RedisApplication.class, args);
//        System.setProperty(net.sf.ehcache.CacheManager.ENABLE_SHUTDOWN_HOOK_PROPERTY,"true");
//        EhCacheCacheManager ehCacheCacheManager = (EhCacheCacheManager) applicationContext.getBean("ehCacheCacheManager");
//        ehCacheCacheManager.initializeCaches();
//        HashMap<String,Integer> map;
//        int c = ~3;
//        System.out.println(c);
    }

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate(new OkHttp3ClientHttpRequestFactory());
    }

    @Bean
    public IdWorker idWorker() {
        return new IdWorker(1, 10);
    }
}
